<?php


	$TEMP->set_file(array('handle' => DIR_VIEW_REGISTRAR . 'studentPayment.html'));
	
	$STUDID		= _GET('studid');
	
	$getStudentInformation 		= $STUD->getStudentInformation($STUDID);
	$getFreshmenSemesterLinker 	= $DSC->getFreshmenSemesterLinker($getStudentInformation['course_idFK']);
	$stud_idPK 			= $getStudentInformation['stud_idPK'];
	$stud_no 			= $getStudentInformation['stud_no'];
	$first_name 		= $getStudentInformation['first_name'];
	$middle_name 		= $getStudentInformation['middle_name'];
	$last_name 			= $getStudentInformation['last_name'];
	$course_idFK 		= $getStudentInformation['course_idFK'];
	$course_desc 		= $getStudentInformation['course_desc'];
	$dept_desc 			= $getStudentInformation['dept_desc'];
	$course_desc 		= $getStudentInformation['course_desc'];
	$course_desc 		= $getStudentInformation['course_desc'];
	$sem_desc 			= $getFreshmenSemesterLinker['sem_desc'];
	$sem_linker_idPK 	= $getFreshmenSemesterLinker['sem_linker_idPK'];
	
	$semesterEnrollmentActive 	= $STUD->getSemesterEnrollmentActive($stud_idPK);
	
	$semesterLabel 			= $DSC->getSemesterLabel($semesterEnrollmentActive['sem_linker_idFK']);
	$semFeesLinkerListing 	= $DSC->getSemFeesLinkerListingActive($semesterEnrollmentActive['sem_linker_idFK']);
	$totalUnits 			= $DSC->getTotalUnitsPerSemesterLinkerActive($semesterEnrollmentActive['sem_linker_idFK'], $stud_idPK);

	$feesListing = '';
	if (!empty($semFeesLinkerListing)) {
		$descFee = '';
		$descVal = '';
		$amountTotalValue = 0;
		foreach($semFeesLinkerListing as $semFeesLinkerListingValue) {
			if ( $semFeesLinkerListingValue['fee_idFK'] == 1 ) {
				$descFee = "Tuition Fee (" . $totalUnits . " units * P " . number_format($semFeesLinkerListingValue['amount']) . ")";
				$descVal = (int)$totalUnits * (int)$semFeesLinkerListingValue['amount'];
			}
			else {
				$descFee = $semFeesLinkerListingValue['fee_desc'];
				$descVal = $semFeesLinkerListingValue['amount'];
			}
			
			$feesListing .= '<div class="reg-fee-enroll">
								<div class="reg-fee-enroll-label">' . $descFee . '</div>
								<div class="reg-fee-enroll-dot">:</div>
								<div class="reg-fee-enroll-value">Php ' . number_format($descVal) . '</div>
							</div>';
			$amountTotalValue += $descVal;
		}
		$feesListing .= '<div class="reg-fee-enroll">
							<div class="reg-fee-enroll-label"><strong>TOTAL</strong></div>
							<div class="reg-fee-enroll-dot"><strong>:</strong></div>
							<div class="reg-fee-enroll-total"><strong>Php ' . number_format($amountTotalValue) . '</strong></div>
						</div>';
	}
	
	if ( isset($_POST['subButton']) ) {
		
		$if_error		= 0;
		
		$listsubjtaken	 = _POST('list_subj_taken');
		
		if ( empty($listsubjtaken) ) { $if_error++; }

		if ( $if_error == 0 ) {

			$expListsubjtaken = explode(', ', $listsubjtaken);

			$studSubjEnrollID = $STUD->getInsertStudSubjEnrollID($stud_idPK, $course_idFK, $activeYear, $expListsubjtaken, $semesterEnrollmentActive['sem_linker_idFK']);
			
		}
		
	}
	
	//$STUD->manualSubjRequisite();

	$TEMP->set_var(array('stud_id'			=> $stud_idPK,
						 'stud_no'			=> $stud_no,
						 'first_name'		=> $first_name,
						 'middle_name'		=> $middle_name,
						 'last_name'		=> $last_name,
						 'course_id'		=> $course_idFK,
						 'course_desc'		=> $course_desc,
						 'dept_desc'		=> $dept_desc,
						 'sem_desc'			=> $sem_desc,
						 'sem_linker_id'	=> $sem_linker_idPK,
						 'total_subj_unit'	=> $totalSubjUnit,
						 'fees'				=> $feesListing,
						 'fullamount'		=> $amountTotalValue,
						 'active_sem'		=> $semesterEnrollmentActive['sem_linker_idFK'],
						 'reg_sub_menu'		=> $pageLib->registrarSubMenu(DIR_IMAGES),
						 'redirect'			=> $REDIRECT,
						 'hash'				=> $HASH,
						 'current_sem'		=> $semesterLabel['sem_desc'] . ' (' . $semesterLabel['sem_code'] . ')',
						));
?>